<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<h1>hello</h1> |world',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                '<h1>hello|world</h1>',
            '</div>',
        ].join('')),
        'Delete a space to merge into H1');

    test(() => assert_selection(
        [
            '<div contenteditable dir="ltr">',
                '<h1>hello</h1><p>|world</p>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable dir="ltr">',
                '<h1>hello|world</h1>',
            '</div>',
        ].join('')),
        'Delete P to merge into H1 with DIR');

    test(() => assert_selection(
        [
            '<div contenteditable dir="ltr">',
                '<h1>hello</h1><p><b>|worl</b>d</p>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable dir="ltr">',
                '<h1>hello|<b>worl</b>d</h1>',
            '</div>',
        ].join('')),
        'Delete B to merge into H1 with DIR and keeping B');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<h1>hello</h1><em>|world</em>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                '<h1>hello|<em>world</em></h1>',
            '</div>',
        ].join('')),
        'Delete EM to merge into H1 with keeping EM');
</script>
